package jtk.project4.fleet.ibatis.dao;

import java.sql.SQLException;
import java.util.List;

import nl.coderight.jazz.dialog.MessageDialog;
import nl.coderight.jazz.dialog.MessageType;
import jtk.project4.fleet.domain.SecComps;
import jtk.project4.fleet.domain.SecComps;
import jtk.project4.fleet.domain.SecComps;

public class SecCompsDao extends IbatisDao{
	
	

	public int deleteSecComps(SecComps seccomps) throws SQLException{
		return (int) getSqlMap().delete("DELETE_SECCOMPS", seccomps);
	}
	public List selectSecComps() throws SQLException {
		List selectSecComps = null;
			selectSecComps=getSqlMap().queryForList("SELECT_ALL_SECCOMPS", null);
		return selectSecComps;
	}
	public int updateSecComps(SecComps seccomps) throws SQLException{
		return (int) getSqlMap().update("UPDATE_SECCOMPS", seccomps);
	}

	public SecComps insertSecComps(SecComps seccomps) throws SQLException{
		return (SecComps) getSqlMap().insert("INSERT_SECCOMPS", seccomps);
	}

	public SecComps selectHiji(int id) throws SQLException{
		return (SecComps) getSqlMap().queryForObject("SELECT_SECCOMPS", id);
	}
		
	public static void main (String args[]) throws SQLException{
		SecComps seccomps;
		//List<SecComps> template;
		seccomps = new SecComps();
		
		//seccomps.setCompId(6);
		//template = new SecCompsDao().selectSecComps();
	//	System.out.println(template.size());
	/*
		System.out.println("SecComps dengan id ="+seccomps.getCompId()+ " ,telah di hapus dari DB");
		
		seccomps.setName("wira");
		seccomps.setFormId(17);
		seccomps.setCompId(19);
		new SecCompsDao().insertSecComps(seccomps); 
		System.out.println("Seccomps dengan nama "+seccomps.getName()+ " telah di insert pada DB");
		System.out.println("Seccomps dengan FormId "+seccomps.getFormId()+ " telah di insert pada DB");
		System.out.println("Seccomps dengan CompId "+seccomps.getCompId()+ " telah di insert pada DB");
	*/	
		seccomps = new SecCompsDao().selectHiji(3); 
		System.out.println("Seccomps dengan nama ="+seccomps.getCompId()+ " telah di dapat pada dari DB");
		seccomps.setName("SANTOSO"); 
		new SecCompsDao().updateSecComps(seccomps);
		System.out.println("update seccomps dengan nama ="+seccomps.getName()+ " ,telah diupdate");
		
	}
}